package com.leicx.guli.product.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.leicx.guli.common.validate.InsertGroup;
import com.leicx.guli.common.validate.RegularString;
import com.leicx.guli.common.validate.UpdateGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;

/**
 * 品牌
 *
 * @author lcx
 * @email at_xiong@163.com
 * @date 2021-03-25 11:13:58
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 品牌id
     */
    @Null(message = "新增时id不能有值", groups = InsertGroup.class)
    @NotNull(message = "更新时id必须有值", groups = UpdateGroup.class)
    @TableId(type = IdType.AUTO)
    private Long brandId;
    /**
     * 品牌名
     */
    @NotEmpty(message = "品牌名称不能为空", groups = {InsertGroup.class, UpdateGroup.class})
    private String name;
    /**
     * 品牌logo地址
     */
    @URL(message = "品牌logo地址不是合法的url", groups = {InsertGroup.class, UpdateGroup.class})
    @NotEmpty(message = "品牌logo地址不能为空", groups = {InsertGroup.class, UpdateGroup.class})
    private String logo;
    /**
     * 介绍
     */
    private String descript;
    /**
     * 显示状态[0-不显示；1-显示]
     */
    @NotNull(message = "显示状态不能为空", groups = {InsertGroup.class, UpdateGroup.class})
    private Integer showStatus;
    /**
     * 检索首字母
     */
//    @Pattern(
//            regexp = "^[a-zA-Z]$",
//            message = "检索首字母必须是一位英文字母",
//            groups = {InsertGroup.class, UpdateGroup.class}
//    )
    @RegularString(min = 1, max = 1,
            groups = {InsertGroup.class, UpdateGroup.class})
    @NotBlank(message = "检索首字母不能为空", groups = {InsertGroup.class, UpdateGroup.class})
    private String firstLetter;
    /**
     * 排序
     */
    @NotNull(message = "排序字段不能为空", groups = {InsertGroup.class, UpdateGroup.class})
    private Integer sort;

}
